<link type="text/css" rel="stylesheet" href="<?php echo $this->basePath('public/css/dbblack/css/ucenter.css'); ?>" />
<link type="text/css" rel="stylesheet" href="<?php echo $this->basePath('public/css/dbblack/css/product.css'); ?>" />

<div class="container clearfix">
    <?php echo $this->partial('shopfront/home/left_menu.phtml'); ?>
    <div class="uc-content">
        <h1 class="title"><span><?php echo $this->translate('退货申请'); ?>：</span></h1>
        <form class="form-search" style="margin: 0;" method="get">
        <div class="mt20 tr">
            <input type="text" style="height: 20px;width: 300px;" name="search_content" value="<?php echo isset($_GET['search_content']) ? $this->escapehtml($_GET['search_content']) : ''; ?>" placeholder="<?php echo $this->translate('输入订单编号'); ?>">&nbsp;
            <button type="submit" class="btn btn-main btn-mini"><?php echo $this->translate('搜索'); ?></button>
            <?php
            $refundState  = $this->frontwebsite()->getOrderConfig('user_order_refund');
            if($refundState == 'true') {
            ?>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <a class="btn btn-main" href="<?php echo $this->url('frontrefund/default', array('action'=>'addRefund')); ?>"><?php echo $this->translate('点此申请退货'); ?></a>
            <?php } ?>
        </div>
        </form>
        <?php if ($this->user_order_refund->getTotalItemCount() > 0) {
            $type_array  = array(1=>$this->translate('退款到账户余额'), 2=>$this->translate('退款到银行'), 3=>$this->translate('退款到第三方支付'));
            $state_array = array(0=>$this->translate('等待处理'), 1=>$this->translate('退款成功'), 2=>$this->translate('退款拒绝'));
            ?>
        <table class="simple address-list mt20">
            <tr>
                <th><?php echo $this->translate('订单编号'); ?></th>
                <th width="150"><?php echo $this->translate('退款方式'); ?></th>
                <th width="150"><?php echo $this->translate('申请时间'); ?></th>
                <th width="100"><?php echo $this->translate('处理状态'); ?></th>
                <th width="160"><?php echo $this->translate('操作'); ?></th>
            </tr>
            <?php foreach ($this->user_order_refund as $log_value) { ?>
                <tr>
                    <td><?php echo $log_value['order_sn']; ?></td>
                    <td><?php echo $type_array[$log_value['refund_type']]; ?></td>
                    <td><?php echo date("Y-m-d H:i:s", $log_value['refund_time']); ?></td>
                    <td><?php echo $state_array[$log_value['refund_state']]; ?></td>
                    <td>
                        <a href="<?php echo $this->url('frontrefund/default/refund_id', array('action'=>'refundShow', 'refund_id'=>$log_value['refund_id'])); ?>"><?php echo $this->translate('查看退货详情'); ?></a>
                        <?php if($log_value['refund_state'] == 0) { ?>
                            &nbsp;&nbsp;
                            <a href="javascript:;" onclick="del_refund(<?php echo $log_value['refund_id']; ?>);"><?php echo $this->translate('删除'); ?></a>
                        <?php } ?>
                    </td>
                </tr>
           <?php } ?>
        </table>
        <div class="page-nav"><?php echo ( count($this->user_order_refund) > 0 ) ? $this->paginationControl($this->user_order_refund, 'Sliding', 'site/dbpage',array('page_url'=>$this->url('frontrefund/default'))) : ""; ?></div>

        <?php } else { echo '<p>' . $this->translate('暂无记录！') . '</p>'; } ?>
    </div>
</div>
<script>
    function del_refund(refund_id) {
        if(window.confirm('<?php echo $this->translate('您确实要删除该记录吗？'); ?>')) {
            $.post("<?php echo $this->url('frontrefund/default',array('action'=>'delRefund')); ?>",{refund_id:refund_id},
                function(data){
                    if(data == 'true') {
                        window.location.reload();
                        return true;
                    } else {
                        alert('<?php echo $this->translate('退货记录删除失败！'); ?>');
                    }
                });
        }
        return false;
    }
</script>